package com.kob.matchingsystem.controller;

import com.kob.matchingsystem.service.MatchingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MtachingController {
    @Autowired
    private MatchingService matchingService;

    @RequestMapping("/player/add/")
    public String addPlayer(@RequestParam MultiValueMap<String ,String>data){
        Integer userId = Integer.parseInt(data.getFirst("user_id"));
        Integer rating = Integer.parseInt(data.getFirst("rating"));
        Integer botId = Integer.parseInt(data.getFirst("bot_id"));
        return matchingService.addPlay(userId,rating,botId);
    }
    @RequestMapping("/player/remove/")
    public String removePlayer(@RequestParam MultiValueMap<String,String>data){
        Integer userId = Integer.parseInt(data.getFirst("user_id"));
        return matchingService.removePlayer(userId);
    }
}
